package cn.jari.erp.inventory.api.impl;

import cn.jari.erp.inventory.dto.InventoryCategoryReference;
import cn.jari.erp.inventory.dto.UpdateInventoryCategoryCommand;
import cn.jari.erp.inventory.dto.DeleteInventoryCategoryCommand;
import cn.jari.erp.inventory.dto.InventoryCategoryDto;
import cn.jari.erp.inventory.dto.CreateInventoryCategoryCommand;
import javax.validation.constraints.NotNull;
import cn.jari.erp.inventory.api.InventoryCategoryService;
import com.csicit.ace.api.annotations.tokens.AutoChooseToken;
import com.csicit.ace.appbase.WebClientBuilderFactory;
import com.csicit.ace.utils.ConditionalOnCloudApp;
import com.csicit.ace.utils.WebClientUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Primary;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Objects;
/*
 * 警告：代码由鲲舟平台生成，请勿手动修改。
 * Warn: This class file is generated by JARI-ACE platform, please do not modify manually。
 */

/**
 * {@link InventoryCategoryService}的远程服务客户端调用代理
 */
@Component
@ConditionalOnCloudApp
@ConditionalOnMissingBean
@Primary
public class InventoryCategoryServiceCloudImpl implements InventoryCategoryService {
    private final WebClientUtils web;

    public InventoryCategoryServiceCloudImpl(@AutoChooseToken WebClientBuilderFactory webclientBuilderFactory) {
        web = new WebClientUtils("http://inventory-service", webclientBuilderFactory);
    }
    @Override
    public InventoryCategoryReference getByName(String name) {
        return web.getUniformWrapped(
                            "/inventory-category/{name}",
                            new ParameterizedTypeReference<>(){},
                            null,
                            name
);
    }
    @Override
    public InventoryCategoryDto createInventoryCategory(CreateInventoryCategoryCommand command) {
        return web.postForUniformWrapped("/inventory-category",
                                                new ParameterizedTypeReference<>(){},
                                                command
);
    }
    @Override
    public InventoryCategoryDto updateInventoryCategory(UpdateInventoryCategoryCommand command) {
        return web.putForUniformWrapped("/inventory-category",
                                                new ParameterizedTypeReference<>(){},
                                                command
);
    }
    @Override
    public InventoryCategoryDto deleteInventoryCategory(DeleteInventoryCategoryCommand command) {
        return web.postForUniformWrapped("/inventory-category/delete",
                                                new ParameterizedTypeReference<>(){},
                                                command
);
    }
}
